<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('钉钉流程实例列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>

                            <li>
                                <label>业务参数：</label>
                                <input type="text" name="businessKey"/>
                            </li>
                            <li>
                                <label>实例标题：</label>
                                <input type="text" name="title"/>
                            </li>


                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:procinst:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var getProcessDetail = [[${@permission.hasPermi('ding:officialFlow:getProcessDetail')}]];
        var prefix = ctx + "ding/officialFlow";
        var dingProcStatus = [[${@dict.getType('ding_proc_status')}]];
        var dingProcResult = [[${@dict.getType('ding_proc_result')}]];
        $(function() {
            var options = {
                url: prefix + "/getMyStartProcessList",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "钉钉流程实例",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: 'id',
                    visible: false
                },
                {
                    field: 'businessKey',
                    title: '业务参数'
                },
                    {
                        field: 'title',
                        title: '实例标题'
                    },

                {
                    field: 'startTime',
                    title: '流程开始时间'
                },
                {
                    field: 'finishTime',
                    title: '流程结束时间'
                },
                    {
                        field: 'processSpendTime',
                        title: '流程用时'
                    },

                    {
                    field: 'type',
                    title: '流程状态',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(dingProcStatus, value);
                        }
                },

                {
                    field: 'procResult',
                    title: '审批结果',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(dingProcResult, value);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-info btn-xs ' + getProcessDetail + '" href="javascript:void(0)" onclick="getProcessDetails(\'' + row.procInstId + '\')"><i class="fa fa-eye"></i>详情</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        function getProcessDetails(processInstanceId) {
            var preViewUrl=prefix+'/getProcessInstanceDetail?processInstanceId='+processInstanceId;
            $.modal.openTab("详情", preViewUrl);
        }
    </script>
</body>
</html>